#!/bin/bash

echo "=== 完整编译测试 ==="

CXX=g++
CXXFLAGS="-I../cbp2make/lib -I../cbp2make/lib/tinyxml -I../cbp2make/src -Ilib -Isrc -Wall -std=c++11 -DAICODER_ENHANCED -m64 -D__WXMSW__ -DwxUSE_UNICODE"
OBJDIR=".objs/test"
mkdir -p $OBJDIR

echo "1. 编译 AI 增强文件..."
$CXX $CXXFLAGS -c src/aicoder_enhancements.cpp -o $OBJDIR/aicoder_enhancements.o
if [ $? -ne 0 ]; then echo "❌ AI 文件编译失败"; exit 1; fi

echo "2. 编译核心文件..."
$CXX $CXXFLAGS -c ../cbp2make/src/cbp2make.cpp -o $OBJDIR/cbp2make.o
if [ $? -ne 0 ]; then echo "❌ 核心文件编译失败"; exit 1; fi

echo "3. 编译库文件..."
$CXX $CXXFLAGS -c ../cbp2make/lib/stlstrings.cpp -o $OBJDIR/stlstrings.o
if [ $? -ne 0 ]; then echo "❌ 库文件编译失败"; exit 1; fi

echo "4. 编译 XML 库文件..."
$CXX $CXXFLAGS -c ../cbp2make/lib/tinyxml/tinyxml.cpp -o $OBJDIR/tinyxml.o
if [ $? -ne 0 ]; then echo "❌ XML 库文件编译失败"; exit 1; fi

echo "✅ 所有文件编译成功!"
echo "测试文件保存在: $OBJDIR/"

# 清理
rm -rf $OBJDIR
